<?php
namespace Admin\Controller;
use Think\Controller;
class BannerController extends CommenController {
    function add_point(){


    $point=D('banner_point');

    if(IS_POST){

      $_POST['up_time']=strtotime(I('post.up_time'),0);
      $_POST['down_time']=strtotime(I('post.down_time'),0);

      $id=$point->add(I('post.'));

      if($id>0){

     $this->success('添加成功',U('banner/lists'),2);die;
// $this->GetLastSql();
        # code...
      }else{
         $this->error('添加失败','',2);die;
      }

    }


    $this->display();
}


function lists_point(){
  $admin=D('banner_point');
  $list = $admin->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
  $this->assign('lists',$list);
  $this->display(); // 输出模板


}


    function add(){

    $point=D('banner');

    if(IS_POST){

      $_POST['img']=$this->upload();


      $id=$point->add(I('post.'));

      if($id>0){

     $this->success('添加成功',U('banner/lists'),2);die;
// $this->GetLastSql();
        # code...
      }else{
         $this->error('添加失败','',2);die;
      }

    }


    $this->display();
}
function lists(){
  $banner=D('banner');
  // object(Think\Model\BannerModel)
  // var_dump($banner);die;
  $list = $banner->relation(true)->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
  // print_r($list);die;
  $this->assign('lists',$list);
  $this->display(); // 输出模板


}


Public function upload(){
// import('ORG.Net.UploadFile');
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize  = 3145728 ;// 设置附件d上传大小
$upload->exts   = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
$upload->savePath =  '';// 设置附件上传目录
$upload->autoSub = true;

$upload->subName = array('date','Ymd');
 $info=$upload->uploadOne($_FILES['img']);
// print_r($info) ;die;
if(!$info) {// 上传错误提示错误信息
$this->error($upload->getError());
}else{// 上传成功 获取上传文件信息


return 'Uploads/'.$info['savepath'].$info['savename'];
 // echo 'Uploads/'.$info['savepath'].$info['savename'];die;
}

}


}
